/*
 * Albareth - an action roleplaying game.
 * Copyright (C) 2008 Jens Anuth
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 *  02110-1301, USA.
 * 
 * $Id: MiniStatusFrame.java 47 2008-05-16 21:01:33Z jens464 $
*/
package albareth.frontend.slick.ui;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import albareth.core.entity.PlayerCharacter;

public class MiniStatusFrame extends UIElement
{
    PlayerCharacter _player;
    int _with = 70;
    
    public MiniStatusFrame(int x, int y, PlayerCharacter player)
    {
        super(x, y);
        setSize(0, 0); //hack to make it mouse-immune
        _player = player;
    }

    public void render(Graphics g, GameContainer container, int screenX,
            int screenY) throws SlickException
    {
        double pctHitsFull =
            (double)_player.getHitpoints() / _player.getMaxHitpoints();
        double pctManaFull = 
            (double)_player.getMana() / _player.getMaxMana();
        
        g.setColor(Color.white);
        g.drawRect(screenX, screenY, _with+2, 6);
        g.drawRect(screenX, screenY+7, _with+2, 6);
        g.setColor(Color.green);
        g.fillRect(screenX+1, screenY+1, (int)(_with*pctHitsFull), 4);

        g.setColor(Color.blue);
        g.fillRect(screenX+1, screenY + 8, (int)(_with*pctManaFull), 4);

    }

}
